﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using QLZJFurnitureSCM.Model;
using QLZJFurnitureSCM.DAL;

namespace QLZJFurnitureSCM.BLL
{
    public class FurnitureTypeService
    {
        private IBaseDAO<FurnitureType> baseDAO = new FurnitureTypeDAO();
        private IProductDAO productDAO = new ProductDAO();
        private IFurnitureTypeDAO furnitureDAO = new FurnitureTypeDAO();

        public FurnitureType InsertFurnitureType(FurnitureType furnitureType)
        {
            return baseDAO.Create(furnitureType);
        }

        public bool Delete(FurnitureType furnitureType)
        {
            return productDAO.DeleteByProductType(furnitureType.TypeId) && baseDAO.Delete(furnitureType);
        }

        public bool Update(FurnitureType furnitureType)
        {
            return baseDAO.Update(furnitureType);
        }

        public List<FurnitureType> ReadAll()
        {
            return baseDAO.ReadAll();
        }

        public List<FurnitureType> FindFurnitureSubTypeByTypeUpId(int typeUpId)
        {
            return furnitureDAO.FindFurnitureSubTypeByTypeUpId(typeUpId);
        }

        public List<FurnitureType> FindFurnitureUpTypeByTypeId(int typeId)
        {
            return furnitureDAO.FindFurnitureUpTypeByTypeId(typeId);
        }

        public bool UpdateFurnitureUpType(int typeId, int typeUpId)
        {
            return furnitureDAO.UpdateFurnitureUpType(typeId, typeUpId);
        }
    }
}
